home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
526-550
/
disk_536
/
wfile
/
src.lzh
/
strpos.c
< prev
next >
Wrap
Text File
|
1991-08-23
|
916b
|
36 lines
/***************************************************************************
* strpos.c: returns index of string2 in string1 or -1 if not found *
* *
* created: Oct-90 Mtwx *
***************************************************************************/
/* --------------------- source code revisions, tracked by RCS ---------- */
/* $Header: Hard0:C-Compiler/src/wfile/rcs/strpos.c,v 1.0 91/08/12 20:27:15 Mtwx Exp $ */
/* $Log: strpos.c,v $
* Revision 1.0 91/08/12 20:27:15 Mtwx
* Initial revision
* */
/* ------------------------------- routines ----------------------------- */
int strpos(char *s1, char *s2)
{
register int i;
int n,pos=0,flag=0;
if(strlen(s2) > strlen(s1)) return -1;
for(i=0;i<strlen(s1)-strlen(s2)+1;i++)
{
n=strncmp(&s1[i],s2,strlen(s2));
if(n==0)
{
pos=i;
flag=1;
break;
}
}
if(!flag) pos=-1;
return pos;
}